#include "gamedialogmanager.h"
#include "gamewindow.h"
#include "gamedialog.h"
#include "player.h"
#include "gametable.h"
#include "shopdialog.h"
#include <QEvent>
#include "battledialog.h"
#include "playerskilldialog.h"

GameDialogManager::GameDialogManager(GameWindow* w)
    :QGraphicsObject(0), _w(w)
{


    _fore = new GameDialogBg(this);

    //shop dialog
    herbalistShop = new HerbalistShopDialog(this, _fore);
    sorcererShop = new SorcererShopDialog(this, _fore);
    pavilionShop = new PavilionShopDialog(this, _fore);
    cemeteryShop = new CemeteryShopDialog(this, _fore);

    messageBox = new GameMessageBox(this, _fore);
    BottomLessBox = new BottomLessDialog(this, _fore,this->getGameWindow()->getTable()->getCurrentPlayer());
    playerRequest = new GamePlayerRequestDialog(this,_fore);
    slotRequest = new GameSlotRequestDialog(this, _fore);
    battleDialog = new BattleDialog(this, _fore);
    tileRequest = new GameTileRequestDialog(this,_fore);
    taoRequest = new GameTaoRequestDialog(this, _fore);
    diceRequest = new GameDiceRequestDialog(this, _fore);
}

QRectF GameDialogManager::boundingRect() const{
    return QRectF();
}

void GameDialogManager::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){

}


GameWindow* GameDialogManager::getGameWindow(){
    return _w;
}

int GameDialogManager::askMessageBox( QString s ){
    messageBox->setText( s );
    return messageBox->execDialog();
}

int GameDialogManager::askBottomLessBox(){

    return BottomLessBox->execDialog();
}
Player* GameDialogManager::askPlayerRequestBox(bool alive){
    return playerRequest->execDialog(alive);
}

GhostSlot* GameDialogManager::askSlotRequestDialog(){
    return slotRequest->execDialog();
}

int GameDialogManager::askTestShop(){
    return herbalistShop->execDialog();
}

VillageTile* GameDialogManager::askTileDialog(){
    return tileRequest->execDialog();
}

int GameDialogManager::askBattleDialog(GhostSlot *s){
    return battleDialog->execDialog(s);
}


GSColor GameDialogManager::askTaoDialog(){
    return taoRequest->execDialog();
}

QList<GameDialogDice*> GameDialogManager::askDiceRoll(int num){
    //clear existing dice before use
    diceRequest->clear();
    diceRequest->execDialog(num);
    return diceRequest->getDiceResult();
}
